#include "sys.h"

u8 code smg[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,//n   u    p                                                                    
	             0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xc8,0xc1,0x8c,0xff,0x7f};
void display(u8 who, u8 number)
{
	LED_buff = P0;
	P0 = 0xff;
	hc138(7);
	hc138(0);

	P0 = 0x01 << who-1;
	hc138(6);
	hc138(0);
	
	P0 = smg[number];
	hc138(7);
	hc138(0);
	P0 = LED_buff;
	delay1ms(1);
}

void show_AIN1()
{
	if(mode_vp1)
	{
		display(1,18);
		display(2,1);
		display(6,(char)(VP1*10)/10);
		display(6,20);
		display(7,(char)(VP1*10)%10);
		display(8,0);
	}else{
		display(1,17);
		display(2,1);
		display(6,VAIN1_VAL/100);
		display(6,20);
		display(7,VAIN1_VAL%100/10);
		display(8,VAIN1_VAL%10);
	}
}

void show_AIN3()
{
	if(mode_vp3)
	{
		display(1,18);
		display(2,3);
		display(6,(char)(VP3*10)/10);
		display(6,20);
		display(7,(char)(VP3*10)%10);
		display(8,0);
	}else{
		display(1,17);
		display(2,3);
		display(6,VAIN3_VAL/100);
		display(6,20);
		display(7,VAIN3_VAL%100/10);
		display(8,VAIN3_VAL%10);
	}
}

void show_mode()
{
	if(mode)
		show_AIN3();
	else
		show_AIN1();
}